www.gusucode.com > 可隐藏可停靠可换肤的 OutLook工具条-源码程序 > 可隐藏可停靠可换肤的 OutLook工具条-源码程序/code/pinoutbar/mybar.cpp
//Download by http://www.NewXing.com #include "stdafx.h" //#include "AutoHideBar.h" //#include "gncase2.h" #include "mybar.h" #include "..\resource.h" ///////////////////////////////////////////////////////////////////////////// // CMyBar static UINT nIcons[] = { IDI_ICON1, IDI_ICON3, IDI_ICON4, IDI_ICON7, IDI_ICON8, IDI_ICON2, IDI_ICON11, IDI_ICON6, IDI_ICON9, IDI_ICON10, IDI_ICON5 }; void CMyBar::InitializeOutlookBar() { // Create the image lists used by the outlook bar. m_ImageSmall.Create (16, 16, ILC_COLOR16|ILC_MASK, 2, 1); m_ImageLarge.Create (32, 32, ILC_COLOR16|ILC_MASK, 2, 1); // initiailize the image lists. for (int i = 0; i < 11; ++i) { HICON hIcon = AfxGetApp()->LoadIcon(nIcons[i]); ASSERT(hIcon); m_ImageSmall.Add(hIcon); m_ImageLarge.Add(hIcon); } int iFolder; // index of the added folder // set the image lists for the outlook bar. m_wndOutlookBar.SetImageList(&m_ImageLarge, CGfxOutBarCtrl::fLargeIcon); m_wndOutlookBar.SetImageList(&m_ImageSmall, CGfxOutBarCtrl::fSmallIcon); m_wndOutlookBar.SetAnimationTickCount(20); m_wndOutlookBar.SetAnimSelHighlight(200); // Add the first folder to the outlook bar. iFolder = m_wndOutlookBar.AddFolder(_T("Shortcuts 1"), 0); // Add items to the folder, syntax is folder, index, text, image, and item data. m_wndOutlookBar.InsertItem(iFolder, 1, _T("Item 1"), 0, NULL); m_wndOutlookBar.InsertItem(iFolder, 2, _T("Item 2"), 1, NULL); m_wndOutlookBar.InsertItem(iFolder, 3, _T("Item 3"), 2, NULL); m_wndOutlookBar.InsertItem(iFolder, 4, _T("Item 4"), 3, NULL); m_wndOutlookBar.InsertItem(iFolder, 5, _T("Item 5"), 4, NULL); m_wndOutlookBar.InsertItem(iFolder, 6, _T("Item 6"), 5, NULL); // Add the second folder to the outlook bar. iFolder = m_wndOutlookBar.AddFolder(_T("Shortcuts 2"), 1); // Add items to the folder, syntax is folder, index, text, image, and item data. m_wndOutlookBar.InsertItem(iFolder, 1, _T("Item 1"), 0, NULL); m_wndOutlookBar.InsertItem(iFolder, 2, _T("Item 2"), 1, NULL); // Select the first folder in the bar. m_wndOutlookBar.SetSelFolder(iFolder); } CMyBar::CMyBar() { m_bFloate = FALSE; m_hParentWnd =NULL ; } CMyBar::~CMyBar() { } BEGIN_MESSAGE_MAP(CMyBar, CPinDockBar) //{{AFX_MSG_MAP(CMyBar) ON_WM_CREATE() //}}AFX_MSG_MAP ON_WM_WINDOWPOSCHANGED() END_MESSAGE_MAP() void CMyBar::AddToDrawBar(CAutoHideBar * pDrawBar) { CRect rt; m_wndOutlookBar.GetClientRect(&rt); m_wndOutlookBar.ShowWindow(SW_SHOW); pDrawBar->AddButton(" OutlookBar ", DRAWBTNSTYLE_GROUP | DRAWBTNSTYLE_SELECT, &m_wndOutlookBar, this, &rt, this, 0); }; void CMyBar::RemoveFromDrawBar(CAutoHideBar * pDrawBar) { CRect rt; pDrawBar->RemoveButton(&m_wndOutlookBar); pDrawBar->Shrink(); pDrawBar->CalcLayout(); pDrawBar->Invalidate(); GetParentFrame()->ShowControlBar(this, TRUE, FALSE); }; ///////////////////////////////////////////////////////////////////////////// // CMyBar message handlers int CMyBar::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CPinDockBar::OnCreate(lpCreateStruct) == -1) return -1; DWORD dwf = CGfxOutBarCtrl::fDragItems|CGfxOutBarCtrl::fEditGroups|CGfxOutBarCtrl::fEditItems|CGfxOutBarCtrl::fRemoveGroups| CGfxOutBarCtrl::fRemoveItems|CGfxOutBarCtrl::fAddGroups|CGfxOutBarCtrl::fAnimation; if(!m_wndOutlookBar.Create(WS_CHILD|WS_VISIBLE, CRect(0,0,0,0), this, 102, dwf)) { TRACE0("Failed to create outlook bar."); return -1; } InitializeOutlookBar() ; // TODO: Add your specialized creation code here return 0; } void CMyBar::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos) { CPinDockBar::OnWindowPosChanged(lpwndpos); // should only be called once, when floated. if( IsFloating() ) { if( m_pDockBar && !m_bFloate ) { m_bFloate = TRUE ; CWnd* pParent = m_pDockBar->GetParent(); if( pParent->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd))) { HWND h = pParent->m_hWnd ; if(h != m_hParentWnd) { m_hParentWnd = h ; g_af.SkinWindow(m_hParentWnd,SKIN_CLASS_NOSKIN) ; } } } else if( m_bFloate ) { m_bFloate = FALSE; } } }